/*nomutex.c*/
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

char str[] = "abcdefghijklmnopqrstuvwxyz123456789";
int index2=0;

void *t1_exe(void *arg){
    while (index2<strlen(str)-1){
        printf("The %dth element of array is %c\n",index2,str[index2]);
        sleep(1);
        index2++;
    }
}

void main() {
    pthread_t pid1,pid2;
    int error1,error2;
    error1=pthread_create(&pid1,NULL, t1_exe,NULL);
    error2=pthread_create(&pid2,NULL, t1_exe,NULL);
    if (error1!=0||error2!=0) {
        printf("pthread_create failed ");
        return ;
    }
    pthread_join(pid1,NULL);
    pthread_join(pid2,NULL);
    return ;
}

